<template>
    <div class="photoinfo-container">
        <h3>{{photoInfo.title}}</h3>
        <p class="subtitle">
            <span>发表时间：{{photoInfo.add_time | dateFormat}}</span>
            <span>点击：{{photoInfo.click}}次</span>
        </p>
        <hr>

        <div class="thumbs">
            <vue-preview :slides="slide1" @close="handleClose"></vue-preview>
        </div>


        <div class="content" v-html="photoInfo.content"></div>
        <comment :id='id'></comment>
    </div>
</template>
<script>
import comment from "../subcomponents/comment";
export default {
  name: "photoinfo",
  data() {
    return {
      id: this.$route.params.id,
      photoInfo: {},
      slide1: []
    };
  },
  components: {
    comment: comment
  },
  created() {
    this.getPhotoInfo();
    this.getThumbs();
  },
  methods: {
    getPhotoInfo() {
      this.$axios.get("getimageInfo/" + this.id).then(result => {
        // console.log(result);
        if (result.data.status === 0) {
          this.photoInfo = result.data.message[0];
        }
      });
    },
    getThumbs() {
      this.$axios.get("getthumimages/" + this.id).then(result => {
        if (result.data.status === 0) {
          result.data.message.forEach(element => {
            element.msrc = element.src;
            element.alt = element.src;
            element.title = element.src;
            element.w = 300;
            element.h = 200;
          });
          this.slide1 = result.data.message;
          //console.log(this.slide1)
        }
      });
    },
    handleClose() {
      console.log("close event");
    }
  }
};
</script>
<style lang="scss" scoped>
.photoinfo-container {
  padding: 3px;
  h3 {
    color: #26a2ff;
    font-size: 13px;
    text-align: center;
    margin: 15px, 0;
  }
  .subtitle {
    font-size: 13px;
    display: flex;
    justify-content: space-between;
  }
  .content {
    font-size: 13px;
    line-height: 30px;
  }
  .thumbs {
    img {
      margin: 10px;
    }
  }
}
</style>


